import { Result } from 'antd';
import { useEffect, useState } from 'react';
import { useModel } from 'umi';
import ReviseView from './ReviseView';
import { Role } from '@/utils/types.d';

const AboAuditPage = () => {
  const { initialState } = useModel('@@initialState');
  const currUser = initialState?.currentUser;
  const [initData, setInitData] = useState<AbnormalOrderTableItem | null>();
  const [searchCondition, setSearchCondition] = useState<{
    selectType?: number;
    ownerId?: string;
  }>({});
  useEffect(() => {
    // 上个界面传递过来的参数
    const params = localStorage.getItem('abnormalParams') || '{}';
    const { currentData, search = {} } = JSON.parse(params);
    setInitData(currentData);
    setSearchCondition(search);
  }, []);
  return (
    <>
      {initData ? (
        <ReviseView
          canSearchUser={currUser?.role === Role.ADMIN}
          data={initData}
          searchCondition={searchCondition}
        />
      ) : (
        <Result title="暂无数据" />
      )}
    </>
  );
};

export default AboAuditPage;
